#include <iostream>
#include <string.h>
using namespace std;

void test1(){
    //有确定的初始化，初始化为10个0
    /* int * p = new int[10](); */
    /* int * p = new int[10];//不一定在所有平台上进行了初始化 */
    int * p = new int[10]{1,2,3,4,5};
    for(int i = 0; i < 10; ++i){
        cout << p[i] << endl;
    }
    delete [] p;
    p = nullptr;

    char * pstr = new char[6]{'h','e','l','l','o','\0'};
    cout << pstr << endl;//可以直接获取字符串内容
    delete [] pstr;
    pstr = nullptr;

    const char * pstr2 = "world";
    cout << sizeof(pstr2) << endl;
    cout << strlen(pstr2) << endl;
    char * p2 = new char[strlen(pstr2) + 1]();
    strcpy(p2,pstr2);
    cout << p2 << endl;
    delete [] p2;
    p2 = nullptr;
}


int main(int argc, char * argv[])
{
    test1();
    return 0;
}

